Skip to content

Conversation

rasbt
Copy link
Owner

@rasbt rasbt commented Mar 8, 2025

Fixes issues with the BPE tokenizer to correctly handle edge cases.

Fixes #558

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@rasbt rasbt marked this pull request as draft March 8, 2025 17:01
@rasbt rasbt marked this pull request as ready for review March 8, 2025 20:44
@rasbt rasbt merged commit f63f04d into main Mar 8, 2025
13 checks passed
@rasbt rasbt deleted the fix-bpe branch March 8, 2025 23:21
@d-kleine
Copy link
Contributor

d-kleine commented Mar 9, 2025

@rasbt About the lowest possible merge rank defined as min_rank = 1_000_000_000, I am not sure if inf would be a better choice (just like in the original BPE implementation) to keep the code resilient. The value 1_000_000_000 might look very specific to users, although it's arbitrary. Also, with multi-modality and growing vocabulary sizes, adjacent token combinations of 1_000_000_000 might be reached at some point in the future, possible breaking the code then.

" min_rank = 1_000_000_000\n",
" bigram = None\n",
" for p in pairs:\n",
" r = self.bpe_ranks.get(p, 1_000_000_000)\n",
" if r < min_rank:\n",
" min_rank = r\n",
" bigram = p\n",

@rasbt
Copy link
Owner Author

rasbt commented Mar 9, 2025

yes, I agree!

rasbt added a commit that referenced this pull request Aug 17, 2025
* Fix BPE bonus materials

* fix bpe implementation

* update

* Add 'Hello, world. Is this-- a test?' test case

* update link to test file

* update path handling

* update path handling

* fix pytest paths
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Encoding issue with "Hello,"
2 participants